<?php

namespace app\api\controller;

use app\common\controller\Api;
use fast\Pinyin;
use think\Db;

class Test extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function t1()
    {
        $list = db('vehicle')->field('id,mergename')->select();
        foreach ($list as $v) {
            $first = Pinyin::get($v['mergename'], true);
            $first = strtoupper(substr($first, 0, 1));
            db('vehicle')->where('id', $v['id'])->update(['first' => $first]);
            echo "[$first]" . $v['mergename'] . '<br/>';
        }
        echo "结束";
    }
}